package com.sports.controller;

import com.sports.pojo.Orders;
import com.sports.service.IOrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/orders")
public class OrdersController {
    @Autowired
    private IOrdersService service;
    @GetMapping
    public List<Orders> list(){
        return service.list();
    }
    @GetMapping("/{id}")
    public Orders getInfo(@PathVariable Integer id) {
            return service.getById(id);
    }
    @PostMapping
    public Integer add(@RequestBody Orders orders){
        int rlt= service.add(orders);
        return rlt;
    }
    @PutMapping
    public Integer update(@RequestBody Orders orders){
        return service.update(orders);
    }
    @DeleteMapping("/{id}")
    public Integer delete(@PathVariable Integer id){
        return service.delete(id);
    }
}
